package com.collection.treesets;

import java.util.TreeSet;

public class GetSizeOfJavaTreeSetExample {
	public static void main(String[] args) {
		   
	    //create TreeSet object
	    TreeSet tSet = new TreeSet();
	   
	    /*
	      To get the size of TreeSet use
	      int size() method of TreeSet class. It returns the number of elements
	      stored in TreeSet object.    
	    */
	    System.out.println("Size of TreeSet : " + tSet.size());
	   
	    //add elements to TreeSet object
	    tSet.add(new Integer("1"));
	    tSet.add(new Integer("2"));
	    tSet.add(new Integer("3"));
	 
	    System.out.println("Size of TreeSet after addition : " + tSet.size());
	   
	    //remove one element from TreeSet using remove method
	    tSet.remove(new Integer("1"));
	    System.out.println("Size of TreeSet after removal : " + tSet.size());
	  }
}
